How to decrease size of c++ source code? [closed]
Posted
by
free0u
on Stack Overflow
See other posts from Stack Overflow
or by free0u
Published on 2010-12-24T16:56:43Z
Indexed on
2010/12/24
17:54 UTC
Read the original article
Hit count: 199
For example
#include <iostream>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cout << i;
}
return 0;
}
Decrease:
#include <fstream>
int main() {
std::ifstream y("input.txt");
std::ofstream z("output.txt");
int n, i = 0;
y >> n;
while(i < n)
z << i++;
exit(0);
}
What's about "fstream"?
std::fstream y("input.txt"), z("output.txt")
It's amazing but output is not correct.) "output.txt" isn't remaking. Output is writing from begin of file.
How to decrease code?
Just for fun)
© Stack Overflow or respective owner